﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SignalRApplication.Contracts;

namespace PoemGame.SignalR.Backend
{
    [Route("api/[controller]")]
    [ApiController]
    public class GameController : ControllerBase
    {
        private readonly ISignalRAppService _service;
        public GameController(ISignalRAppService service)
        {
            _service = service;
        }
        [HttpGet("GetPlayerByUserName")]
        public async Task<PlayerDto> GetPlayerByUserName([FromQuery] string name)
        {
            return await _service.GetPlayerByUserName(name);
        }

        [HttpGet("GetPlayerGames")]
        public async Task<List<GameDto>> GetPlayerGames([FromQuery] string name)
        {
            return await _service.GetPlayerGames(name);
        }

        [HttpGet("GetGame")]
        public async Task<GameDetailDto> GetGame([FromQuery] string gameid)
        {
            return await _service.GetGame(Guid.Parse(gameid));
        }

        [HttpPost("UpdateNickName")]
        public async Task UpdateNickName(UpdateNickNameDto dto)
        {
            await _service.UpdateNickName(dto);
        }
    }
}
